package com.miui.systemui.tools

import java.util.regex.Pattern

class ParsedFigmaUrl(val fileId: String, val nodeId: String) {
    companion object {
        fun parseFigmaUrl(url: String?): ParsedFigmaUrl? {
            // 正则表达式匹配 file_id 和 node_id
            val regex =
                "https://www\\.figma\\.com/design/([a-zA-Z0-9]+)(?:/[^?]*)?\\?node-id=([0-9-]+)"
            val pattern = Pattern.compile(regex)
            val matcher = pattern.matcher(url)

            if (matcher.find()) {
                val fileId = matcher.group(1)
                val nodeId = matcher.group(2)
                return ParsedFigmaUrl(fileId, nodeId)
            }
            return null
        }
    }
}
